<?php
require_once "./db_config.php";
if(isset($_POST['status'])){
    $id=$_POST['id'];
//    修改
    if($_POST['status']=='0'){
        $dept=$_POST['dept'];
        $start_date=$_POST['start_date'];
        $end_date=$_POST['end_date'];
        $sql="UPDATE turnlist SET dept='$dept',start_date='$start_date',end_date='$end_date' WHERE tempId='$id'";
        $result=mysqli_query($conn,$sql);
        if(! $result )
        {
            die('error: ' . mysqli_error($conn));
        }else {
            echo "success";
        }
//        停止
    }else if ($_POST['status']=='1'){
        $sql="UPDATE turnlist SET `state`=3 WHERE tempId='$id'";
        $result=mysqli_query($conn,$sql);
        if(! $result )
        {
            die('error: ' . mysqli_error($conn));
        }else {
            echo "success";
        }
//        评价
    }else if ($_POST['status']=='2'){
        $evaluate=$_POST['evaluate'];
        $sql="UPDATE turnlist SET evaluate=$evaluate WHERE tempId='$id'";
        $result=mysqli_query($conn,$sql);
        if(! $result )
        {
            die('error: ' . mysqli_error($conn));
        }else {
            echo "success";
        }
//        删除
    }else{
        $sql="DELETE FROM turnlist WHERE tempId='$id'";
        $result=mysqli_query($conn,$sql);
        if(! $result )
        {
            die('error: ' . mysqli_error($conn));
        }else {
            echo "success";
        }
    }
}
mysqli_close($conn);
